#include<stdio.h>
int main()
{
	int n,m,a[1010],k;
	scanf("%d %d",&n,&m);
	int y=0,Y=10000;
  for(int i=1;i<=n;i++)
  {
    scanf("%d",&a[i]);
  }
  while(m--)
  {
    scanf("%d",&k);
   // printf("%d ",k);
  int l=1,r=n;
  while(l<r)
  {
    int zhong=(r+l)>>1;
    if(a[zhong]>=k)
      r=zhong;
    else 
	l=zhong+1;
  }
  //printf("%d\n",a[l]);
  if(a[l]<k){
  y=k-a[l];
  //printf("%d  ",k);
  if(Y>y)
      Y=y;
  continue;
	}
	else if(a[l]-k<=k-a[l-1])
      y=a[l]-k;
    else y=k-a[l-1];
    if(Y>y)
      Y=y;
	}
	printf("%d",Y);
	return 0;
}